//
//  DateViewController.m
//  UIpickview
//
//  Created by student on 16/2/23.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "DateViewController.h"

@interface DateViewController ()

@end

@implementation DateViewController
- (IBAction)date:(id)sender
{
    NSDateFormatter *f=[[NSDateFormatter alloc]init];
    [f setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString *str=[f stringFromDate:self.datepicker.date];
    UIAlertView *alertview=[[UIAlertView alloc]initWithTitle:@"现在的时间是" message:str delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alertview show];
}
- (IBAction)datechanged:(UIDatePicker *)sender
{
    NSDate *now = [NSDate date];
    NSTimeInterval t=[now timeIntervalSinceDate:self.datepicker.date];
    self.label.text=[NSString stringWithFormat:@"你所选的时间和当前间隔%g天",fabs(t/60.0/60.0/24.0)];
    
    
   
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
